<template>
    <div class="location">
      <div class="title">
        <div class="back-wrapper">
          <back></back>
        </div>
        {{$route.query.cinemaName}}
      </div>
      <div class="content" id="allMap" style=""></div>
    </div>
</template>

<script>
  import back from '../../../components/back/back'
  import {MP} from '../../../common/js/map'
  import {getStorage,setStorage} from "../../../common/js/localStorage";

  export default {
        name: "location",
        components:{
          'back':back
        },
        data(){
          return{
            lng:'',
            lat:''
          }
        },
        mounted() {
          this.lng = this.$route.query.longitude
          this.lat = this.$route.query.latitude
          this.name = this.$route.query.cinemaName
          if(getStorage('isRefresh')){
            setStorage('isRefresh',false)
            if(!getStorage('isRefresh')){
              window.history.go(0)
            }
          }

          this.$nextTick(()=>{
            MP(global.MAP_AK).then(BMap =>{
              // let map = new BMap.Map("allmap");
              // let point = new BMap.Point(116.404, 39.915)
              console.log(map)

                let map = new BMap.Map('allMap');
                let point = new BMap.Point(116.404, 39.915);
                map.centerAndZoom(point, 15)
                var geolocation = new BMap.Geolocation();
                geolocation.getCurrentPosition((r) => {
                  if (r.point) {
                    var point = new BMap.Point( this.lng, this.lat);//用当前定位的经纬度查找省市区街道等信息

                    var gc = new BMap.Geocoder();
                    gc.getLocation(point, function(rs){
                      var addComp = rs.addressComponents;
                    });
                    let markers = new BMap.Marker(r.point);
                    map.addOverlay(markers);
                    map.panTo(r.point);
                    map.centerAndZoom(r.point, 16);
                  }
                })


            })
          })
        }
    }
</script>

<style scoped lang="stylus">
  .anchorBL
    display none !important
  .location
    position absolute
    height 100%
    width 100%
    background #101011
    user-select none
    overflow hidden
    .title
      position relative
      padding 10px 0
      height 22px
      line-height 22px
      text-align center
      font-size 16px
      color #ffffff
      .back-wrapper
        position absolute
        left 0
        top 10px
        width 36px
        height 22px
    .content
      height calc(100% - 42px)
</style>
